<?php

define('DEDE_FILE','');

require_once dirname(__FILE__).'/model/common.inc.php';
$id = min(intval($id),9999999);
$type = (string)$type;
$dtp = new DedeTemplate();
switch($type)
{
	case 'doctor':
		$doctor = $dsql->getone("select * from `#@__doctor` where id ='$id'");
		if(!$doctor)
		{
			showmsgs('信息不存在', '-1');
		}
		$navtitle = $doctor[name];
		$navkeyword = $doctor[name];
		$navdescription = strip_tags($doctor[description],'');
		$doctor[professions] = $doctor[professions] == '' ? 0 : $doctor[professions];
		$asks = $dsql->setquery('select * from `#@__ask` where tid = '.$doctor[professions].' or tid2 = '.$doctor[professions]. ' limit 0,10');
		$dsql->execute();
		while($ask = $dsql->getarray())
		{
			$asks[] = $ask;
		}

		$dtp->LoadTemplate(ASKROOT.'/template/default/show_doctor.htm');
		break;
	case 'skill':
		$skill = $dsql->getone("select * from `#@__archives` where id ='$id'");
		if(!$skill)
		{
			showmsgs('信息不存在', '-1');
		}
		$navtitle = $skill[name];
		$navkeyword = $skill[name];
		$navdescription = strip_tags($skill[description],'');
		$asks = $dsql->setquery('select * from `#@__ask` limit 0,10');
		$dsql->execute();
		while($ask = $dsql->getarray())
		{
			$asks[] = $ask;
		}
		$dtp->LoadTemplate(ASKROOT.'/template/default/show_skill.htm');
		break;
	case 'news':
		$news = $dsql->getone("select s.*, a.body as description from `#@__archives` as s left join `#@__addonarticle` as a on a.aid=s.id where s.id ='$id'");
		if(!$news)
		{
			showmsgs('信息不存在', '-1');
		}
		$navtitle = $news[name];
		$navkeyword = $news[name];
		$navdescription = strip_tags($news[description],'');
		$asks = $dsql->setquery('select * from `#@__ask` limit 0,10');
		$dsql->execute();
		while($ask = $dsql->getarray())
		{
			$asks[] = $ask;
		}
		$dtp->LoadTemplate(ASKROOT.'/template/default/show_news.htm');
		break;
	case 'hospital':
		$hospital = $dsql->getone("select * from `#@__hospital` where id ='$id'");
		$navtitle = $hospital[name];
		$navkeyword = $hospital[name];
		$navdescription = strip_tags($hospital[intro],'');
		$asks = $dsql->setquery('select * from `#@__ask`  limit 0,10');
		$dsql->execute();
		while($ask = $dsql->getarray())
		{
			$asks[] = $ask;
		}
		$dtp->LoadTemplate(ASKROOT.'/template/default/show_hospital.htm');
		break;
}

if($cfg_ask_rewrite=='Y')
{
	$dtp->Display();
	myecho();
	exit();
}
else
{
	$dtp->Display();
}
?>